package com.linxiao.call.controller;

import com.alibaba.fastjson2.JSONObject;
import com.linxiao.call.service.ICrmWebCallService;
import com.linxiao.call.vo.CrmWebCallVO;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 对接天润语音通知
 *
 * @Author qiqi
 * @Date 2022/6/7 15:04
 * @Version 1.0
 */
@RestController
@RequestMapping("/crm/tr/")
public class CrmWebCallController {
    public Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private ICrmWebCallService crmWebCallService;

    @RequestMapping("/webCall")
    public AjaxResult webCall(CrmWebCallVO crmWebCallVO) {
        logger.info("CrmWebCallController.webCall 语音通知WebCall请求参数  crmWebCallVO = {}", JSONObject.toJSONString(crmWebCallVO));
        if (Objects.isNull(crmWebCallVO)) {
            return AjaxResult.error("语音通知参数不能为空！！！");
        }
        if (StringUtils.isEmpty(crmWebCallVO.getRequestUniqueId())) {
            return AjaxResult.error("语音通知参数【requestUniqueId】不能为空！！！");
        }
        if (crmWebCallVO.getDeptId() == null) {
            return AjaxResult.error("语音通知参数【deptId】不能为空！！！");
        }
        if (crmWebCallVO.getTel() == null) {
            return AjaxResult.error("语音通知参数【tel】不能为空！！！");
        }
        AjaxResult ajaxResult = crmWebCallService.webCall(crmWebCallVO);
        return ajaxResult;

    }


}
